package com.hzqy.service.advertisement;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import com.hzqy.persistence.dao.advertisement.AdvertisementDao;
import com.hzqy.service.core.GenericServiceBean;
import com.hzqy.web.vo.PmsUserVo;
import com.hzqy.web.vo.advertisement.AdvertisementViewVo;
import com.hzqy.web.vo.advertisement.AdvertisementVo;

@Service
public class AdvertisementServiceBean extends GenericServiceBean<PmsUserVo,AdvertisementDao, Integer>{
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	
	@Resource
	private AdvertisementDao advertisementDao;
	@Override
	public AdvertisementDao getEntityDao() {
		return advertisementDao;
	}
	
	public List<AdvertisementVo> getAdvertisement(String f_ccadver_contentid,String f_ccadver_type){
		List<AdvertisementVo> advertisementList = new ArrayList<AdvertisementVo>();
		AdvertisementVo advertisementVo = null;
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("f_ccadver_contentid", f_ccadver_contentid);
		map.put("f_ccadver_type", f_ccadver_type);
		List<Integer> ids = advertisementDao.selectAdvertisementId(map);
		LOG.debug("f_am_id = "+ids);
		if(ids != null){
			for(int i=0;i<ids.size();i++){
				advertisementVo = advertisementDao.selectAdvertisement(ids.get(i));
				if(advertisementVo != null){//可能为无效前插
					advertisementList.add(advertisementVo);
				}
			}
		}
		return advertisementList;
	}
	
	public List<AdvertisementViewVo> getAdvertisementView(String f_am_id){
		int f_amv_advertisementid = Integer.parseInt(f_am_id);
		List<AdvertisementViewVo> advertisementViewList = advertisementDao.selectAdvertisementViewList(f_amv_advertisementid);
		return advertisementViewList;
	}
	
}
